from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime, Integer
from sqlalchemy.dialects.mysql import LONGTEXT
from sqlalchemy.sql import func
from app.db.database import Base

class Homepage(Base):
    __tablename__ = "homepages"
    
    id = Column(Integer, primary_key=True, index=True)
    title = Column(String(200), nullable=False)
    content = Column(LONGTEXT, nullable=True)  # 富文本内容，使用LONGTEXT支持更大的内容
    version = Column(Integer, nullable=False, default=1)
    is_published = Column(Boolean, default=False)
    is_active = Column(Boolean, default=True)
    created_by = Column(Integer, nullable=True)  # 创建者ID
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), onupdate=func.now()) 